<?php

namespace AppBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\JsonResponse;


use AppBundle\Entity\Task;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;

use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;

class ContainerController extends Controller
{

    // 1 container logger日志信息
    /**
     * @Route("/container", name="container", requirements={"max": "\d+"})
     */
    public function showAction(Request $request,$max = 1)
    {

        $logger = $this->container->get('logger');
        $logger->emergency('emergency 你妹');
        $logger->alert('alert 你妹');
        $logger->critical('critical 你妹');
        $logger->error('error 你妹');
        $logger->warning('warning 你妹');
        $logger->notice('notice 你妹');
        $logger->info('info 你妹');
        $logger->debug('debug 你妹');
        $logger->log('log 你妹');
        exit;

    }



    // 2 container 服务信息
    /**
     * @Route("/containerService", name="containerService", requirements={"max": "\d+"})
     */
    public function containerServiceAction(Request $request,$max = 1)
    {
        $name = '生产一个服务页面';

        $messageGenerator = $this->container->get('app.message_generator');
        $message = $messageGenerator->getHappyMessageArrayRand();
        $this->addFlash('success', $message);


        //渲染模板
        return $this->render('container/containerServiceAction.html.twig', array('name' => $name));

    }



    // 3 container 服务增加参数
    /**
     * @Route("/containerServiceParameter", name="containerServiceParameter", requirements={"max": "\d+"})
     */
    public function containerServiceParameterAction(Request $request,$max = 1)
    {
        $name = '生产一个服务页面';

        // 查看是否可以生成记录
        // $isLoggingEnabled = $this->container->getParameter('enable_generator_logging');

        $messageGenerator = $this->container->get('app.message_generator');
        $message = $messageGenerator->getHappyMessage();




        //渲染模板
        // return $this->render('container/containerServiceAction.html.twig', array('name' => $name));

    }



}
